from langgraph_sdk import get_sync_client


client = get_sync_client(url="http://127.0.0.1:2024")


for chunk in client.runs.stream(
    None,       # Thread less run
    "agent",    # Name of assistant. Defined in langgraph.json.
    input={
        "messages": [{
            "role": "human",
            # "content": "乌鲁木齐今天的天气怎么样？"
            "content": "请获取下当前用户的所有信息"
        }]
    },
    stream_mode="messages-tuple",
    # stream_mode="messages",
    # stream_mode="updates",
    config={'configurable': {'user_name': 'Lily'}}
):
    # print(f"Receiving new event of type: {chunk.event}...")
    # print(chunk.data)
    # print("\n\n")

    if isinstance(chunk.data, list) and 'type' in chunk.data[0] and chunk.data[0]['type'] == 'AIMessageChunk':
        print(chunk.data[0]['content'], end='|')



